//
// Created by 34649 on 2022/3/1.
//

#ifndef AYIN_MUDUO_HTTP_TYPE_H
#define AYIN_MUDUO_HTTP_TYPE_H
#include <string>
#include "map"
#include "muduo/base/Logging.h"
#include "muduo/net/Buffer.h"
#include "assert.h"
#include "memory"
#include <unordered_map>
namespace http{
    using string=std::string;
    using hmap=std::map<string ,string>;
    const string CRLF="\r\n";
    const string basePath = "./assert";
    using Buffer=muduo::net::Buffer;
    enum class HTTP_VERSION{
        HTTP_1=0,
        HTTP_11=1,
        HTTP_2,
        HTTP_3
    };
    enum class METHOD{
        GET=0,
        POST,
        DELETE,
        PUT,
    };
    enum class HTTP_CODE{
        Continue=100,
        OK=200,
        Created=201,
        Accepted=202,
        Multiple_Choice=300,
        Bad_Request=400,
        Unauthorized=401,
        Forbidden=403,
        Not_Found=404,
        Internal_Server_Error=500
    };

    enum class HTTP_PARSE_STATUS{
        INIT=0,
        REQUEST_LINE,
        HEADER,
        CONTENT,
        FINISHED
    };

    enum class HTTP_PARSE_CODE{
        OK = 0,                         //解析成功
        DUPLICATE_KEY_ERROR=1,          //请求头中出现重复 key 值
        UNDEFINED_VALUE,                //请求头中未定义的值
        UNKNOWN_HTTP_METHOD,            //未知请求方法
        UNKNOWN_HTTP_VERSION,            //未知 http 版本
        INCOMPLATE_PACK,                 //包不完整
        NO_CONTENT,                      //没有content内容
    };
    enum class CONTENT_TYPE{
        NONE=0,
        PLAIN,
        HTML,
        JAVASCRIPT,
        XML,
        JSON,
        FORM_DATA,
        FORM_URLENCODED
    };
    const std::unordered_map<CONTENT_TYPE, string> contentTypeMap = {
        {CONTENT_TYPE::HTML, "text/html"},
        {CONTENT_TYPE::PLAIN,"text/plain"},
        {CONTENT_TYPE::NONE,"none"},
        {CONTENT_TYPE::JAVASCRIPT,"application/javascript"},
        {CONTENT_TYPE::XML,"application/xml"},
        {CONTENT_TYPE::FORM_DATA,"multipart/form-data"},
        {CONTENT_TYPE::JSON,"application/json"},
        {CONTENT_TYPE::FORM_URLENCODED,"application/x-www-form-urlencoded"}
    };
    const std::map<HTTP_VERSION,string> versionMap={{HTTP_VERSION::HTTP_1,"HTTP/1.0"},
                                                        {HTTP_VERSION::HTTP_11,"HTTP/1.1"},
                                                        {HTTP_VERSION::HTTP_2,"HTTP/2.0"},
                                                        {HTTP_VERSION::HTTP_3,"HTTP/3.0"}};
    const std::map<HTTP_CODE,string> httpCodeMap={{HTTP_CODE::OK,"OK"},
                                                         {HTTP_CODE::Accepted,"Accepted"},
                                                         {HTTP_CODE::Bad_Request,"Bad Reqeust"},
                                                         {HTTP_CODE::Continue,"Continue"},
                                                         {HTTP_CODE::Created,"Created"},
                                                         {HTTP_CODE::Forbidden,"Forbidden"},
                                                         {HTTP_CODE::Internal_Server_Error,"Internal Server Error"},
                                                         {HTTP_CODE::Multiple_Choice,"Multiple Choice"},
                                                         {HTTP_CODE::Not_Found,"Not Found"},
                                                         {HTTP_CODE::Unauthorized,"Unauthorized"}};
}

#endif //AYIN_MUDUO_HTTP_TYPE_H
